package com.ihr360.shared.encryption.convertor;

import com.ihr360.commons.lang.StringUtils;
import com.ihr360.encryption.MysqlCipherInitializer;

import javax.persistence.Converter;

@Converter
public class StringCryptoConverter extends AbstractCryptoConverter<String> {

    public StringCryptoConverter() {
        this(new MysqlCipherInitializer());
    }

    public StringCryptoConverter(MysqlCipherInitializer cipherInitializer) {
        super(cipherInitializer);
    }

    @Override
    boolean isNotNullOrEmpty(String attribute) {
        return StringUtils.isNotEmpty(attribute);
    }

    @Override
    String stringToEntityAttribute(String dbData) {
        return dbData;
    }

    @Override
    String entityAttributeToString(String attribute) {
        return attribute;
    }
}